package cn.echoedu.specifics;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import cn.echoedu.daoconstants.TableName;
import cn.echoedu.entity.Department;
import cn.echoedu.entity.Image;
import cn.echoedu.entity.SchoolNotify;
import cn.echoedu.entity.SchoolNotifyImage;
import cn.echoedu.entity.Teacher;
import cn.echoedu.util.L;
import cn.echoedu.util.StringUtil;

public class SpecSchoolNotifyImage extends BaseSpec{
    private final String T="SpecSchoolNotifyImage************>>";
	@Override
	public <T> PreparedStatement getPreparedInsert(Connection con,
			TableName tableName, T currentPojo) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> PreparedStatement getPreparedInsertRunning(Connection con,
			TableName tableName, T currentPojo) throws SQLException {
		// TODO Auto-generated method stub
		SchoolNotifyImage schoolnotifyimage = (SchoolNotifyImage)currentPojo;
		final String M = "getPreparedInsertRunning**********>>";
	    L.p(T+M);
		String sql  = "insert into schoolnotifyimage(schoolnotifyid," +
				"imageid) values"+StringUtil.getBeforeTheBsrackets()
				+"?,?"+StringUtil.getAfterTheBrackets();
		PreparedStatement preparedstatement = con.prepareStatement(sql);
		preparedstatement.setInt(1,schoolnotifyimage.getSchoolnotify().getSchoolnotifyid());
		preparedstatement.setInt(2,schoolnotifyimage.getImage().getImageid());
		return preparedstatement;
	}

	@Override
	public Object getPojo(ResultSet rs) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> PreparedStatement getPreparedUpdate(Connection con,
			TableName tableName, T oldPojo, T currentPojo) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> String getPreparedInsertGetPrimaryKeySql(Connection con,
			TableName tableName, T currentPojo) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object getLeftJoinPojo(ResultSet rs) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object getPojoBySql(ResultSet rs) throws SQLException {
		// TODO Auto-generated method stub
		SchoolNotifyImage schoolnotifyimage = new SchoolNotifyImage();
		schoolnotifyimage.setSchoolnotifyimageid(rs.getInt("schoolnotifyimageid"));
		SchoolNotify schoolnotify = new SchoolNotify();
		schoolnotify.setSchoolnotifyid(rs.getInt("schoolnotify.schoolnotifyid"));
		schoolnotify.setTitle(rs.getString("schoolnotify.title"));
		schoolnotify.setPlace(rs.getString("schoolnotify.place"));
		schoolnotify.setContent(rs.getString("schoolnotify.content"));
		schoolnotify.setFilepath(rs.getString("schoolnotify.filepath"));
		schoolnotify.setStarttime(rs.getTimestamp("schoolnotify.starttime"));
		schoolnotify.setEndtime(rs.getTimestamp("schoolnotify.endtime"));
		schoolnotify.setRemindertime(rs.getTimestamp("schoolnotify.remindertime"));
		schoolnotify.setShowinhomepage(rs.getInt("schoolnotify.showinhomepage"));
		schoolnotify.setHitcount(rs.getInt("schoolnotify.hitcount"));
		schoolnotify.setPublishtime(rs.getTimestamp("schoolnotify.publishtime"));
		Teacher teacher = new Teacher();
		teacher.setTeachernumber(rs.getString("schoolnotify.teachernumber"));
		schoolnotify.setTeacher(teacher);
		Department department = new Department();
		department.setDepartmentcode(rs.getInt("schoolnotify.departmentcode"));
		schoolnotify.setDepartment(department);
		schoolnotify.setLikenum(rs.getInt("schoolnotify.likenum"));
		schoolnotify.setDislikenum(rs.getInt("schoolnotify.dislikenum"));
		Image image = new Image();
		image.setImageid(rs.getInt("image.imageid"));
		image.setImagename(rs.getString("image.imagename"));
		image.setImagesrc(rs.getString("image.imagesrc"));
		schoolnotifyimage.setSchoolnotify(schoolnotify);
		schoolnotifyimage.setImage(image);
		return schoolnotifyimage;
	}

	@Override
	public <T> PreparedStatement getPreparedListInsert(Connection con,
			TableName tableName, T currentPojo) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> PreparedStatement getPreparedListInsertRunning(Connection con,
			TableName tableName, T currentPojo) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

}
